package linkedlist.delete;

import linkedlist.Node;

/**
 * @Author wangtengyu
 * @Create 2018-09-03-11:28 在一个链表中，删除数据为x的节点
 */
public class RecursionDeletor {


  public <T> Node<T> deleteValue(Node<T> head, T value) {
    if (head == null) {
      return head;
    }

    if (head.getData() == value) {
      head = deleteValue(head.getNext(), value);
    } else {
      if (head.getNext() == null) {
        return head;
      }
      head.setNext(deleteValue(head.getNext(), value));
    }

    return head;

  }

}
